package com.just.company_server.controller;

import com.just.company_server.model.Company;
import com.just.company_server.service.CompanyService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : baibaiwucahng
 * @date : 2020/3/8  23:16
 */

@RestController
@RequestMapping("/api/v1/company")
public class CompanyController {
    @Resource
    private CompanyService companyService;

    @GetMapping("/")
    public List<Company> getAllCompany() {
        return companyService.getAllCompany();
    }

    @GetMapping("/one/{id}")
    public Company getCompanyById(@PathVariable("id") Integer id) {
        return companyService.getCompanyById(id);
    }

    @PostMapping("/")
    public void insertCompany(@RequestBody Company company) {
        companyService.insertCompany(company);
    }

    @DeleteMapping("/")
    public void deleteCompanyById(@RequestBody Integer id) {
        companyService.deleteCompanyById(id);
    }

    @PutMapping("/")
    public void editCompany(@RequestBody Company company) {
        companyService.editCompany(company);
    }

}
